<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FSF.qsort</title>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../styles/styles.css">
<script language="javascript" src='../links.js' type="text/javascript"></script>
</head>
<body>

<h1>qsort</h1>
<div class=navbar>
<a href="../index.html">main</a> |
<a href="index.html">FarStandardFunctions</a>
</div>

<div class=shortdescr>
The <dfn>FSF.qsort</dfn> function allows to sort an array of any type of 
data using the QuickSort algorithm. 
</div>

<pre class=syntax>
void WINAPI qsort(
  void *Base,
  size_t NElem,
  size_t Width,
  int (<b>__cdecl</b> *fcmp)(const void *, const void *)
);
</pre>

<h3>Parameters</h3>
<div class=descr>
  <div class=dfn>Base</div>
  <div class=dfndescr>Start of target array.
  </div>

  <div class=dfn>NElem</div>
  <div class=dfndescr>Array size in elements.
  </div>

  <div class=dfn>Width</div>
  <div class=dfndescr>The size of each element in bytes.
  </div>

  <div class=dfn>fcmp</div>
  <div class=dfndescr>

  User-defined comparison function that must be declared with __cdecl - C-style 
  calling convention. This function takes two arguments - <em>elem1</em> and
  <em>elem2</em>. These arguments are the pointers to the array elements. <em>fcmp</em> 
  function must compare these elements and return an integer value:
  <table border=0>
   <tr><td>*elem1 &lt; *elem2</td><td>- fcmp returns value < 0</td></tr>
   <tr><td>*elem1 == *elem2</td><td>- fcmp returns value == 0</td></tr>
   <tr><td>*elem1  &gt; *elem2</td><td>- fcmp returns value > 0</td></tr>
  </table>
  </div>
</div>

<h3>Return value</h3>
<div class=descr>
None.
</div>

<h3>Remarks</h3>
<div class=descr>
<ol>
<li>See the C/C++ run-time library reference for more information.
<li>If you need to pass user-defined data to the compare function, you should 
    use the <a href="qsortex.html">qsortex</a> function instead.
<li>The sort implemented by the qsort and qsortex functions is not stable. 
    In other words, the order for the elements that are equal according to 
    the compare function is not defined. The order can change when the array 
    is sorted repeatedly.

</ol>
</div>

<h3>Example</h3>
<div class=descr>
</div>


<div class=see>See also:</div><div class=seecont>
<a href="bsearch.html">FSF.bsearch</a>,
<a href="qsortex.html">FSF.qsortex</a>
</div>

</body>
</html>
